package com.hh.commen.service.impl;/*
 * @Description:TODO 描述
 * @Author: tongZhao
 * @date: 2023/8/17
 */

import com.hh.commen.bean.AttributeVo;
import com.hh.commen.bean.Common;
import com.hh.commen.mapper.CommonMapper;
import com.hh.commen.service.CommonService;
import com.hh.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommonServiceImpl implements CommonService {

    @Autowired
    private CommonMapper commonMapper;

    @Override
    public ResultVo region() {
        List<Common> regionList= commonMapper.region();
        return ResultVo.success(regionList);
    }

    @Override
    public ResultVo country(String regionCode) {
        List<Common> countryList= commonMapper.country(regionCode);
        return ResultVo.success(countryList);
    }

    @Override
    public ResultVo province(String countryCode) {
        List<Common> provinceList= commonMapper.province(countryCode);
        return ResultVo.success(provinceList);
    }

    @Override
    public ResultVo city(String provinceCode) {
        List<Common> cityList= commonMapper.city(provinceCode);
        return ResultVo.success(cityList);
    }

    @Override
    public ResultVo county(String cityCode) {
        List<Common> countyList= commonMapper.county(cityCode);
        return ResultVo.success(countyList);
    }

    /**
     * 拿到所有的库区属性
     * @return
     */
    @Override
    public ResultVo getAllAttribute() {
        List<AttributeVo> attributes =  commonMapper.getAllAttribute();
        return ResultVo.success(attributes);
    }
}
